<?
include_once("includes/header.php");
?>
<link type="text/css" href="styles/style.css" rel="stylesheet" />
<?
$codigo = "";
if (isset($_GET["codigo"]))
    $codigo = $_GET["codigo"];

function GetSelected($query)
{
    $array;
    $result = mysql_query($query);
    if ($result)
    {
        for ($i = 0; $i < mysql_num_rows($result); $i++)
        {
            $ret[mysql_result($result, $i)] = true;
        }
        return $ret;
    }
    else
        return false;
}

$diagnostico;
$titulo = 'Plantilla Diagn&oacute;stico Pap';
include('menu.php');
$query = "select codigo from template_pap_diagnostico_pap group by codigo order by codigo";
?>
<script type="text/javascript">
    $(function(){
        $("#formulario").load("cargaTemplatePapDiagnostico.php?codigo=" + $("#plantilla").val());

        $("#botonPlantilla").click(function()
        {
            $("#formulario").load("cargaTemplatePapDiagnostico.php?codigo=" + $("#plantilla").val());
        });
        $("#fieldsetDiagnostico").append('<label>C&oacute;digo: </label><input type="text" name="codigo" id="codigo" /><input type="submit" value="Guardar" />')
        $("#templateButton").click(function(){
            $("#formulario").load("cargaTemplatePapDiagnostico.php?codigo=" + $("#plantilla").val());             
        });
        $("#formulario").ajaxStop(function(){
            $("#fieldsetDiagnostico").append('<div id="codigoDiv"><label>C&oacute;digo: </label><input type="text" name="codigo" id="codigo" value="'+ $("#plantilla").val() +'" /><div>');
            $("#fieldsetDiagnostico").append("<div class='save'><a href='#' class='saveButton'><img alt='guardar' title='Guardar' src='imagenes/guardar.png'/></a></div>");
        });
        $(".saveButton").live("click", function(event){
            $("#formTemplate").submit();
            event.preventDefault();
        });
    });
</script>
</head>
<body>
    <div class="pageContainer">
        <form id="formTemplate" action="guardaTemplatePapDiagnostico.php" method="post">
            <? include 'includes/inputPlantilla.php' ?>
            <div id="formulario">
                <? include "papDiagnostico.php"; ?>

            </div>
        </form>
    </div>
</body>
</html>